package com.basic.business.memoType.service.impl;

import com.basic.common.constant.CacheConstants;
import com.basic.common.core.redis.RedisCacheUtils;
import org.springframework.stereotype.Service;
import com.basic.common.core.service.impl.BaseServiceImpl;
import com.basic.business.memoType.domain.TOrdersMemoType;
import com.basic.business.memoType.service.ITOrdersMemoTypeService;
import com.basic.business.memoType.mapper.TOrdersMemoTypeMapper;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;

/**
 * 备注类型Service业务层处理
 *
 * @author zhaoxy_jn@163.com
 */
@Service
public class TOrdersMemoTypeServiceImpl extends BaseServiceImpl<TOrdersMemoTypeMapper,TOrdersMemoType> implements ITOrdersMemoTypeService {

    @Resource
    private TOrdersMemoTypeMapper memoTypeMapper;

    @PostConstruct
    public void init(){
        resetMemoTypeCache();
    }

    @Override
    public int updateStatusByIds(String[] ids, String status) {
        return memoTypeMapper.updateStatusByIds(ids, status);
    }

    public List<TOrdersMemoType> getNormalMemoType() {
        return memoTypeMapper.getNormalMemoType();
    }

    @Override
    public void resetMemoTypeCache() {
        // 清空缓存
        RedisCacheUtils.clearCache(CacheConstants.MEMO_TYPE_REDIS_KEY + "*");
        // 加载缓存
        RedisCacheUtils.setCacheObject(CacheConstants.MEMO_TYPE_REDIS_KEY, getNormalMemoType());
    }
}
